<template>
	<view id="app">
		<view class="homeTop">
			<image :src="homeTop"></image>
		</view>
		<uv-navbar title="我的" :border="false" titleStyle="color:#fff;" placeholder bg-color="rgba(0,0,0,0)">
			<template slot="left"></template>
		</uv-navbar>
		<view class="container pr zi10">
			<view class="df pl20 w100p aic">
				<view class="f1 df w100p">
					<view class="wh140 mr20">
						<uv-avatar :src="userinfo.avatar" size="140rpx"></uv-avatar>
					</view>
					<view class="f1 df fdc">
						<view class="df">
							<view class="cw f32 fw5 ptb20">{{userinfo.nickname}}</view>
							<uv-icon name="edit-pen" color="#fff" size="50rpx" @click="handle('member/mine/avatar')" v-if="is_login == 1"></uv-icon>
						</view>
						<view class="cccc f30">UID:{{userinfo.ids}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="container pr zi10">
			<view class="mt30  bgw br15 pr zi100 w100p df fdc">
				<view class="f30 ptb30 c000 plr20">课程订单</view>
				<view class="df w100p mb30">
					<view class="f1 df ver" @click="handle('member/order/order')">
						<uv-icon name="order" size="60rpx" color="#000"></uv-icon>
						<view class="ptb15 f28 c000">全部订单</view>
					</view>
					<view class="f1 df ver pr"  @click="handle('member/order/order?type=2')">
						<uv-icon name="clock" size="60rpx" color="#000">
						</uv-icon>
						<view class="ptb15 f28 c000">待核销</view>
						<view class="pa badgey" v-if="userinfo.order2_count > 0">
							<uv-badge type="error" max="99" :value="userinfo.order2_count"></uv-badge>
						</view>
					</view>
					<view class="f1 df ver pr" @click="handle('member/order/order?type=4')">
						<uv-icon name="more-circle" size="60rpx" color="#000"></uv-icon>
						<view class="ptb15 f28 c000">待评价</view>
						<view class="pa badgey" v-if="userinfo.order5_count > 0">
							<uv-badge :isDot="true" type="error"></uv-badge>
						</view>
					</view>
					<view class="f1 df ver" @click="handle('member/order/order?type=5')">
						<uv-icon name="refund" custom-prefix="custom-icon" size="60rpx" color="#000"></uv-icon>
						<view class="ptb15 f28 c000">退款售后</view>
					</view>
				</view>
			</view>
		</view>
		<view class="container pr zi10">
			<view class=" bgw br15 pr zi100 w100p df fdc">
				<view class="df w100p">
					<view class="f1 df fdc mtb20 mlr10  bgef br15 h130">
						<view class="h50 c666 f30 ptb20 plr20">积分</view>
						<view class="h80 df">
							<view class="f1 df c000 f30 plr20">{{userinfo.score}}</view>
							<view class="w120 df aic jcc bginfo brcustomer">
								<uv-icon name="gift" color="#fff" size="60rpx"></uv-icon>
							</view>
						</view>
					</view>
					<view class="f1 df fdc mtb20 mlr10  bgef br15 h130" @click="handle('member/mine/coupon')">
						<view class="h50 c666 f30 ptb20 plr20">优惠券</view>
						<view class="h80 df">
							<view class="f1 df c000 f30 plr20">{{userinfo.coupon_count}}</view>
							<view class="w120 df aic jcc bgwaring brcustomer">
								<uv-icon name="empty-coupon" color="#fff" size="60rpx"></uv-icon>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--view class="container pr zi10">
			<view class="w100p bgw df ptb15 br15">
				<view class="w185 h260 ml40 mr20">
					<image :src="kchb"></image>
				</view>
				<view class="pt50 df fdc">
					<view class="f36 c000 fw8">生成专属课程海报</view>
					<viwe class="f28 c666 mt10 lh40">
						通过转发专属课程海报分享朋友圈或者好友，邀请好友下单，即可获得课程优惠券。
					</viwe>
				</view>
			</view>
		</view-->
		<view class="container pr zi10">
			<view class="w100p bgw df ptb15 br15" @click="poster()">
				<view class="w185 h260">
					<image :src="zyhb"></image>
				</view>
				<view class="pt50 df fdc">
					<view class="f36 c000 fw8">生成专属主页海报</view>
					<viwe class="f28 c666  mt10 lh40">
						通过转发专属主页海报分享朋友圈或者好友，扫码即可访问自己的主页。
					</viwe>
				</view>
			</view>
		</view>
		<view class="container pr zi10">
			<view class=" bgw  pr zi100 w100p df fdc">
				<view class="f30 ptb30 c000 plr20 mb20">我的服务</view>
				<view class="df w100p mb30">
					<view class="f1 df ver"  @click="handle('member/mine/order/order')">
						<uv-icon name="shigongdingdan" custom-prefix="custom-icon" size="50rpx" color="#666"></uv-icon>
						<view class="pt20 pb15 f28 c666">施工订单</view>
					</view>
					<view class="f1 df ver pr" @click="handle('member/mine/collection')">
						<uv-icon name="star" size="60rpx" color="#666"></uv-icon>
						<view class="ptb15 f28 c666">课程收藏</view>
					</view>
					<view class="f1 df ver pr" @click="handle('member/mine/brower')">
						<uv-icon name="zuji" custom-prefix="custom-icon" size="50rpx" color="#666">
						</uv-icon>
						<view class="pt20 pb15 f28 c666">我的足迹</view>
					</view>
					<view class="f1 df ver" @click="handle('member/message/message')">
						<uv-icon name="xiaoxi" custom-prefix="custom-icon" size="50rpx" color="#666"></uv-icon>
						<view class="pt20 pb15 f28 c666">我的消息</view>
					</view>
				</view>
				<view class="df w100p mb30">
					<view class="f1 df ver" @click="handle('member/mine/edit')">
						<uv-icon name="setting"  size="60rpx" color="#666"></uv-icon>
						<view class="ptb15 f28 c666">修改资料</view>
					</view>
					<view class="f1 df ver" @click="handle('member/mine/case')">
						<uv-icon name="file-text" size="60rpx" color="#666"></uv-icon>
						<view class="ptb15 f28 c666">案例上传</view>
					</view>
					<view class="f1 df ver" @click="handle('member/mine/tool')">
						<uv-icon name=""  size="60rpx" color="#666"></uv-icon>
						<view class="ptb15 f28 c666">工具上传</view>
					</view>
					<view class="f1 df ver pr" @click="handle('member/mine/auth')">
						<uv-icon name="shimingrenzheng" custom-prefix="custom-icon" size="50rpx" color="#666">
						</uv-icon>
						<view class="pt20 pb15 f28 c666">实名认证</view>
					</view>
					
				</view>
				<view class="df w100p mb30">
					<view class="f1 df ver" @click="handle('member/mine/personal')">
						<uv-icon name="subtitle_unblock_light" custom-prefix="custom-icon" size="50rpx" color="#666"></uv-icon>
						<view class="pt20 pb15 f28 c666">成为师傅</view>
					</view>
					<view class="f1 df ver"  @click="handle('member/mine/comment/comment')">
						<uv-icon name="pingjia1" custom-prefix="custom-icon" size="60rpx" color="#666"></uv-icon>
						<view class="ptb15 f28 c666">施工评价</view>
					</view>
					<view class="f1 df ver pr">
						<button type="default" open-type="contact" class="zixun"  hover-class="none">
						<uv-icon name="kefu1" custom-prefix="custom-icon" size="60rpx" color="#666"></uv-icon>
						<view class="pt20 pb15 f28 c666">平台客服</view>
						</button>
					</view>
					<view class="f1 df ver">
						
					</view>
				</view>
			</view>
		</view>
		<uv-popup ref="poster" mode="center" custom-style="min-height: 850rpx;" bgColor="">
			<view class="poster-popup">
				<view class="poster-img">
					<image :src="posterImg" mode="aspectFit"></image>
				</view>
				<view class="poster-Btn rows">
					<view class="posterBtn btnl f1" @click="hideImg()">
						取消
					</view>
					<view class="posterBtn btnr f1" @click="saveImg()">
						保存
					</view>
				</view>
			</view>
		</uv-popup>
		<uv-tabbar :value="3" iconSize="50rpx" activeColor="#00a0e8" inactiveColor="#9ea09f" zIndex="1000">
			<uv-tabbar-item text="首页" @click="reLaunch()">
				<template v-slot:active-icon>
					<image class="wh50" :src="memberSelected"></image>
				</template>
				<template v-slot:inactive-icon>
					<image class="wh50" :src="memberSelecte"></image>
				</template>
			</uv-tabbar-item>
			<uv-tabbar-item text="课程" icon="grid" @click="redirect('member/course/course')"></uv-tabbar-item>
			<uv-tabbar-item text="消息" icon="chat"  @click="redirect('member/message/message',true)"></uv-tabbar-item>
			<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
		</uv-tabbar>
	</view>
	</view>
</template>

<script>
	let that;
	export default {
		data() {
			return {
				homeTop: this.util.config.host + '/static/images/mbg.jpg',
				refundIcon: this.util.config.host + '/static/images/refund.jpg',
				memberSelected: this.util.config.host + '/static/images/homed.png',
				memberSelecte: this.util.config.host + '/static/images/home.png',
				kchb:this.util.config.host+'/static/images/kchb.jpg',
				zyhb:this.util.config.host+'/static/images/zyhb.jpg',
				is_login: 0,
				posterImg:"",
				userinfo: {
					id: 0,
					ids:"",
					is_audty:0,
					nickname: '未登录',
					avatar: this.util.config.host + '/static/images/logo.jpg',
					score:0,
					order2_count: 0,
					order5_count: 0,
					coupon_count:0,
				},
			}
		},
		onLoad(){
			that = this;
			if(uni.getStorageSync('QLXG_token')){
				this.is_login = 1;
			}
		},
		onShow(){
			if(uni.getStorageSync('QLXG_token')){
				this.is_login = 1;
			}
			if(this.is_login == '1'){
				this.getUserInfo();
			}
		},
		methods: {
			poster:function(){
				if(this.is_login == 0){
					uni.navigateTo({
						url:"/pages/member/index/login"
					})
					return false;
				}
				if(this.userinfo.is_audty == 0){
					uni.showModal({
						title: '认证提示',
						content: '需审核认证通过',
						confirmText:'去认证',
						cancelText:'不需要',
						success: function (res) {
							if (res.confirm) {
								uni.navigateTo({
									url:'/pages/member/mine/personal'
								})
							} 
						}
					});
					return false;
				}
				uni.showLoading({
					title:'正在生成...'
				})
				that.request({
					url:'/api/share/member',
					success:function(rlt){
						uni.hideLoading();
						if(rlt.code == 200){
							that.posterImg = rlt.data;
							that.$refs.poster.open();
						}
					}
				})
				
			},
			saveImg(){
				let img = that.posterImg;
				that.util.downloadImg(img);
				
			},
			hideImg(){
				that.$refs.poster.close();
			},
			getUserInfo:function(){
				if(this.is_login == 0){
					return false;
				}
				this.request({
					url:"/api/user/info",
					success:function(rlt){
						that.userinfo = rlt.data;
					}
				})
			},
			handle(e){
				if(this.is_login == 0){
					uni.navigateTo({
						url:"/pages/member/index/login"
					})
					return false;
				}
				uni.navigateTo({
					url:'/pages/'+e
				});
			},
			redirect:function(e,isLogin=false){
				if(isLogin == true){
					if(!uni.getStorageSync('QLXG_token')){
						uni.navigateTo({
							url:"/pages/member/index/login"
						})
						return false;
					}
				}
				uni.redirectTo({
					url:"/pages/"+e,
				})
			},
			reLaunch:function(){
				uni.reLaunch({
					url:"/pages/index/index",
				})
			}
		}
	}
</script>

<style scoped>
	.homeTop {
		position: fixed;
		width: 750rpx;
		height: 460rpx;
		z-index: 1;
	}
	.badgey {
		top: 8rpx;
		right: 45rpx;
	}
	.brcustomer {
		border-radius: 30rpx 0 15rpx 0;
	}
	.zixun{background-color: #fff !important;border: 0 solid #fff !important;line-height: 1.0; font-size: 28rpx;display: flex; flex-direction: column; align-items: center;}
	.zixun::after{border:initial;}
	.poster-popup{width:720rpx;height:750rpx;}
	.poster-popup .poster-img{width:720rpx;height:750rpx;}
	.posterBtn{margin:15rpx 20rpx; padding:10rpx 15rpx; text-align: center;font-size: 26rpx; border-radius: 10rpx;}
	.btnl{background:#fff;border:1px solid #fff; color:#545454;}
	.btnr{background:#5D79FF;border:1px solid #5D79FF; color:#fff;}
</style>